import sys
import numpy as np

sys.path.append("../utils")

from utils import OpRunner, compare, verify_result
import time


def main():
    func = OpRunner("./build/libop.so", 5, pint_time=True)
    minvalue = 1
    maxvalue = 10
    shape = [10 * 1024 * 11]
    for dtype in [np.int8, np.float32, np.int32, np.float16]:
    # for dtype in [np.int8]:
        input_data = np.random.uniform(minvalue, maxvalue, shape).astype(dtype)
        x1 = np.random.uniform(minvalue, maxvalue, shape).astype(dtype)
        x2 = np.random.uniform(minvalue, maxvalue, shape).astype(dtype)
        value = np.random.uniform(minvalue, maxvalue, [1]).astype(dtype)
        output = np.zeros(shape, dtype=dtype)
        func([input_data, x1, x2, value, output], [-1])
        real_result = (input_data + x1 * x2 * value).astype(dtype)
        print(output[-10:])
        print(real_result[-10:])
        if verify_result(output, real_result):
            print(f"{dtype}成功")
        print("----------------------------")
    


if __name__ == "__main__":
    main()
